package study;

import java.util.ArrayList;

public class ArrayListDemo2 {
    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();

        //增加元素
        list.add("aaa");
        list.add("aaa");

        list.add("bbb");
        list.add("ccc");

        //删除元素
        /*boolean result1 = list.remove("aaa");
        System.out.println(result1);
        boolean result2 = list.remove("ddd");
        System.out.println(result2);*/
        /*String remove = list.remove(0);
        System.out.println(remove);*/

        //修改元素
        /*String result = list.set(1, "ddd");
        System.out.println(result);*/

        //查询元素
        /*String s = list.get(0);
        System.out.println(s);*/

        //遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println(list);
    }
}
